home *** CD-ROM | disk | FTP | other *** search
/ Gold Medal Software 1 / Gold Medal Software Volume 1 (Gold Medal) (1994).iso / prog / tpwprog6.arj / GINPUT.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1992-07-02  |  1.6 KB  |  70 lines

  1. { ginput.pas -- Get input via TInputDialog }
  2.  
  3. program Ginput;
  4.  
  5. {$R ginput.res}
  6.  
  7. uses WinTypes, WinProcs, WObjects, StdDlgs;
  8.  
  9. const
  10.  
  11.   id_Menu = 100;    { Menu resource ID }
  12.   cm_Prompt = 101;  { Prompt command ID }
  13.  
  14. type
  15.  
  16.   GinputApplication = object(TApplication)
  17.     procedure InitMainWindow; virtual;
  18.   end;
  19.  
  20.   PGinputWindow = ^GinputWindow;
  21.   GinputWindow = object(TWindow)
  22.     Buffer: array[0 .. 64] of Char;
  23.     constructor Init(AParent: PWindowsObject; ATitle: PChar);
  24.     procedure GetInput(var Msg: TMessage);
  25.       virtual cm_First + cm_Prompt;
  26.   end;
  27.  
  28. { GinputApplication }
  29.  
  30. {- Initialize GinputApplication object's window }
  31. procedure GinputApplication.InitMainWindow;
  32. begin
  33.   MainWindow := New(PGinputWindow, Init(nil, 'Ginput'))
  34. end;
  35.  
  36.  
  37. { GinputWindow }
  38.  
  39. {- Construct GinputWindow object }
  40. constructor GinputWindow.Init(AParent: PWindowsObject; ATitle: PChar);
  41. begin
  42.   TWindow.Init(AParent, ATitle);
  43.   Attr.Menu := LoadMenu(HInstance, PChar(id_Menu));
  44.   Buffer[0] := Chr(0)  { Empty buffer }
  45. end;
  46.  
  47. {- Prompt for input into GinputWindow's Buffer field }
  48. procedure GinputWindow.GetInput(var Msg: TMessage);
  49. begin
  50.   Application^.ExecDialog(New(PInputDialog,
  51.     Init(@Self, 'Input Dialog', 'Please enter something: ',
  52.     Buffer, Sizeof(Buffer))))
  53. end;
  54.  
  55. var
  56.  
  57.   GinputApp: GinputApplication;
  58.  
  59. begin
  60.   GinputApp.Init('GinputApp');
  61.   GinputApp.Run;
  62.   GinputApp.Done
  63. end.
  64.  
  65.  
  66. {--------------------------------------------------------------
  67.   Copyright (c) 1991 by Tom Swan. All rights reserved.
  68.   Revision 1.00    Date: 3/12/1991
  69. ---------------------------------------------------------------}
  70.